#ifndef __CONTROL_H
#define __CONTROL_H
#include <curl/curl.h>
#include "mainwindow.h"
#include "webwidget.h"
#include "plugin.h"

struct shelfCommand
{
    shelfCommand(std::string name, std::string usage):name(name),usage(usage){}
    std::string name;
    std::string usage;
};

  class Control //is singleton
  {
  public:
      static Control* Instance();
      WebWidget* Shelf_consoleView;
      WebWidget* Shelf_webView;
      unsigned int consoleSize;
      std::vector<shelfCommand> commands;
      std::string getNameFromURI(std::string uri);
      void newShelf(std::string uri, bool internal = false);
      void addNotification(std::string icon, std::string hover, std::string jscript);
      std::string getFavicon(std::string url);
      std::vector<WebWidget*> webviews;
      Gtk::Notebook notebook;
      std::vector<Gtk::ScrolledWindow*> windows;
      std::vector<Plugin*> plugins;
      Plugin* getPluginByName(std::string name);
      WebWidget* getWebWidgetByJSContext(JSContextRef ctx);
      WebWidget* getWebWidgetByView(WebKitWebView* webView);
      int getIdByView(WebKitWebView* webView);
      WebWidget* getActiveWebWidget();
      void plug(std::string command);
      bool pluginUpdater();
      int getCurrentShelf();
  protected:
      Control();
      Control(const Control&);
      Control& operator= (const Control&);
  private:
      static Control* pinstance;
      std::string escapeName(std::string name);
  };

#endif
